package org.zzz.pcdc;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;
import java.sql.SQLException;

/**
 * Druid数据源手动配置类
 * 包含数据源核心配置、连接池参数、监控Servlet和Filter
 */
@Configuration
public class DruidConfig {

    /**
     * 配置Druid数据源（核心配置）
     * 通过@ConfigurationProperties绑定application.yml中的配置
     */
    @Bean
    @ConfigurationProperties(prefix = "spring.datasource") // 绑定配置前缀
    public DataSource druidDataSource() throws SQLException {
        DruidDataSource dataSource = new DruidDataSource();

        return dataSource;
    }
}
